/**
 * Project Name:scapp-web
 * File Name:AppointmentController.java
 * Package Name:com.sc.controller
 * Date:2018年7月2日下午5:51:29
 * Copyright (c) 2018, bluemobi All Rights Reserved.
 */

package com.sc.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sc.pojo.Appointment;
import com.sc.pojo.Customer;
import com.sc.service.AppointmentService;
import com.sc.service.CustomerService;

/**
 * Description:   <br/>
 * Date:     2018年7月2日 下午5:51:29 <br/>
 * @author   huanglei
 * @version
 * @see
 */
@Controller
public class AppointmentController {
    @Autowired
    private AppointmentService appointmentService;
    @Autowired
    private CustomerService customerservice;
    
    
    
   
    /**
     *根据电话查询用户是否存在于用户表中 
     * */
    @ResponseBody
    @RequestMapping(value = "insertAppointment")
   public int selectAppointmentbyPhone(String name ,String cphone,int hid,String aimage,String yname){
        System.out.println("录入预约申请信息,客户表基本信息，分配经纪人,电话+"+cphone);
       
        List<Customer> lists=  customerservice.selectbyPhone(cphone);
        List<Appointment> lista=appointmentService.selectAppointmentbyPhone(cphone);
         System.out.println("数组长度"+lists.size());
        int flag=0;
        if(lista.size()==0&lists.size()==0){
         Map<String, Object> map=new HashMap<String, Object>();
         map.put("wxname", yname);
         map.put("wxphone", cphone);
         map.put("yname", name);
         map.put("wxhid", hid);
         map.put("aimage",aimage);
         flag=appointmentService.insertAppointment(map);
         System.out.println("插入长度："+flag);
         }else{
             flag=0;
         }
        System.out.println("输出长度："+flag);
         return flag;
        
    }
  
  

}

